import { memo, useEffect } from "react";
import Layout from "../../components/layout";
import { CURRENT_ORG } from "../../constant";
import { useDispatch } from "react-redux";
import { orgType, setCurrentOrg } from "../../store/org";

const Home = memo(() => {
  const dispatch = useDispatch();
  useEffect(() => {
    const currentOrg = JSON.parse(
      localStorage.getItem(CURRENT_ORG) ?? "{}"
    ) as orgType;
    if (currentOrg.id) {
      const { id, name } = currentOrg;
      dispatch(setCurrentOrg({ id, name }));
    }
  }, []);
  return (
    <>
      <Layout />
    </>
  );
});

export default Home;
